home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / larn.lha / bill.c < prev    next >
C/C++ Source or Header  |  1995-11-19  |  8KB  |  262 lines

  1. /* bill.c */
  2. #include "header.h"
  3. #include "larndefs.h"
  4.  
  5. # ifdef MAIL
  6. # include "player.h"
  7. # ifdef VMS
  8. # define MAILTMP    "sys$scratch:"
  9. # else
  10. # define MAILTMP    "/tmp/#"
  11. # endif
  12. static int pid;
  13. static char mail600[sizeof(MAILTMP)+sizeof("mail600")+20];
  14. # endif
  15. /*
  16.  *  function to create the tax bill for the user
  17.  */
  18. # ifdef MAIL
  19. static letter1()
  20. # else
  21. static letter1(gold)
  22. long gold;
  23. # endif
  24.   {
  25. # ifdef MAIL
  26.   sprintf(mail600,"%s%dmail600",MAILTMP,pid); /* prepare path */
  27.   if (lcreat(mail600) < 0) { write(1,"can't write 600 letter\n",23); return(0);}
  28. #ifndef RFCMAIL
  29.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  30. #endif /*RFCMAIL*/
  31. # endif
  32. #ifdef RFCMAIL
  33.   lprcat("From: LRS (Larn Revenue Service)\n");
  34.   lprcat("Subject: Undeclared Income\n\n");
  35. #else /*RFCMAIL*/
  36.   standout("From:"); lprcat("  the LRS (Larn Revenue Service)\n");
  37.   standout("\nSubject:"); lprcat("  undeclared income\n");
  38. #endif /*RFCMAIL*/
  39.   lprcat("\n   We heard you survived the caverns of Larn.  Let me be the");
  40.   lprcat("\nfirst to congratulate you on your success.  It is quite a feat.");
  41.   lprcat("\nIt must also have been very profitable for you.");
  42.   lprcat("\n\n   The Dungeon Master has informed us that you brought");
  43. # ifdef MAIL
  44.   lprintf("\n%d gold pieces back with you from your journey.  As the",(long)c[GOLD]);
  45. # else
  46.   lprintf("\n%d gold pieces back with you from your journey.  As the", gold);
  47. # endif
  48.   lprcat("\ncounty of Larn is in dire need of funds, we have spared no time");
  49.   lprintf("\nin preparing your tax bill.  You owe %d gold pieces as",
  50. # ifdef MAIL
  51.     (long)c[GOLD]*TAXRATE);
  52. # else
  53.     gold * TAXRATE);
  54. # endif
  55.   lprcat("\nof this notice, and is due within 5 days.  Failure to pay will");
  56.   lprcat("\nmean penalties.  Once again, congratulations, We look forward");
  57.   lprcat("\nto your future successful expeditions.\n");
  58. # ifdef MAIL
  59.   lwclose();
  60. # endif
  61.   return(1);
  62.   }
  63.  
  64. static letter2()
  65.   {
  66. # ifdef MAIL
  67.   sprintf(mail600,"%s%dmail600",MAILTMP,pid); /* prepare path */
  68.   if (lcreat(mail600) < 0) { write(1,"can't write 601 letter\n",23); return(0);}
  69. #ifndef RFCMAIL
  70.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  71. #endif /*RFCMAIL*/
  72. # endif
  73. #ifdef RFCMAIL
  74.   lprcat("From: King (His Majesty King Wilfred of Larndom)\n");
  75.   lprcat("Subject: A Noble Deed\n\n");
  76. #else /*RFCMAIL*/
  77.   standout("From:"); lprcat("  His Majesty King Wilfred of Larndom\n");
  78.   standout("\nSubject:"); lprcat("  a noble deed\n");
  79. #endif /*RFCMAIL*/
  80.   lprcat("\n   I have heard of your magnificent feat, and I, King Wilfred,");
  81.   lprcat("\nforthwith declare today to be a national holiday.  Furthermore,");
  82.   lprcat("\nhence three days, Ye be invited to the castle to receive the");
  83.   lprcat("\nhonour of Knight of the realm.  Upon thy name shall it be written. . .");
  84.   lprcat("\nBravery and courage be yours.");
  85.   lprcat("\nMay you live in happiness forevermore . . .\n");
  86. # ifdef MAIL
  87.   lwclose();
  88. # endif
  89.   return(1);
  90.   }
  91.  
  92. static letter3()
  93.   {
  94. # ifdef MAIL
  95.   sprintf(mail600,"%s%dmail600",MAILTMP,pid); /* prepare path */
  96.   if (lcreat(mail600) < 0) { write(1,"can't write 602 letter\n",23); return(0);}
  97. #ifndef RFCMAIL
  98.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  99. #endif /*RFCMAIL*/
  100. # endif
  101. #ifdef RFCMAIL
  102.   lprcat("From: Endelford (Count Endelford)\n");
  103.   lprcat("Subject: You Bastard!\n\n");
  104. #else /*RFCMAIL*/
  105.   standout("From:"); lprcat("  Count Endelford\n");
  106.   standout("\nSubject:"); lprcat("  You Bastard!\n");
  107. #endif /*RFCMAIL*/
  108.   lprcat("\n   I heard (from sources) of your journey.  Congratulations!");
  109.   lprcat("\nYou Bastard!  With several attempts I have yet to endure the");
  110.   lprcat(" caves,\nand you, a nobody, makes the journey!  From this time");
  111.   lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
  112. # ifdef MAIL
  113.   lwclose();
  114. # endif
  115.   return(1);
  116.   }
  117.  
  118. static letter4()
  119.   {
  120. # ifdef MAIL
  121.   sprintf(mail600,"%s%dmail600", MAILTMP,pid); /* prepare path */
  122.   if (lcreat(mail600) < 0) { write(1,"can't write 603 letter\n",23); return(0);}
  123. #ifndef RFCMAIL
  124.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  125. #endif /*RFCMAIL*/
  126. # endif
  127. #ifdef RFCMAIL
  128.   lprcat("From: Mainair (Mainair, Duke of Larnty)\n");
  129.   lprcat("Subject: High Praise\n\n");
  130. #else /*RFCMAIL*/
  131.   standout("From:"); lprcat("  Mainair, Duke of Larnty\n");
  132.   standout("\nSubject:"); lprcat("  High Praise\n");
  133. #endif /*RFCMAIL*/
  134.   lprcat("\n   With a certainty a hero I declare to be amongst us!  A nod of");
  135.   lprcat("\nfavour I send to thee.  Me thinks Count Endelford this day of");
  136.   lprcat("\nright breath'eth fire as of dragon of whom ye are slayer.  I");
  137.   lprcat("\nyearn to behold his anger and jealously.  Should ye choose to");
  138.   lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
  139.   lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
  140. # ifdef MAIL
  141.   lwclose();
  142. # endif
  143.   return(1);
  144.   }
  145.  
  146. static letter5()
  147.   {
  148. # ifdef MAIL
  149.   sprintf(mail600,"%s%dmail600", MAILTMP,pid); /* prepare path */
  150.   if (lcreat(mail600) < 0) { write(1,"can't write 604 letter\n",23); return(0);}
  151. #ifndef RFCMAIL
  152.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  153. #endif /*RFCMAIL*/
  154. # endif
  155. #ifdef RFCMAIL
  156.   lprcat("From: StMary (St. Mary's Children's Home)\n");
  157.   lprcat("Subject: These Poor Children\n\n");
  158. #else /*RFCMAIL*/
  159.   standout("From:"); lprcat("  St. Mary's Children's Home\n");
  160.   standout("\nSubject:"); lprcat("  these poor children\n");
  161. #endif /*RFCMAIL*/
  162.   lprcat("\n   News of your great conquests has spread to all of Larndom.");
  163.   lprcat("\nMight I have a moment of a great man's time.  We here at St.");
  164.   lprcat("\nMary's Children's Home are very poor, and many children are");
  165.   lprcat("\nstarving.  Disease is widespread and very often fatal without");
  166.   lprcat("\ngood food.  Could you possibly find it in your heart to help us");
  167.   lprcat("\nin our plight?  Whatever you could give will help much.");
  168.   lprcat("\n(your gift is tax deductible)\n");
  169. # ifdef MAIL
  170.   lwclose();
  171. # endif
  172.   return(1);
  173.   }
  174.  
  175. static letter6()
  176.   {
  177. # ifdef MAIL
  178.   sprintf(mail600, "%s%dmail600", MAILTMP, pid); /* prepare path */
  179.   if (lcreat(mail600) < 0) { write(1,"can't write 605 letter\n",23); return(0);}
  180. #ifndef RFCMAIL
  181.   lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
  182. #endif
  183. # endif
  184. #ifdef RFCMAIL
  185.   lprcat("From: CancerSociety (The National Cancer Society of Larn)\n");
  186.   lprcat("Subject: Hope\n\n");
  187. #else /*RFCMAIL*/
  188.   standout("From:"); lprcat("  The National Cancer Society of Larn\n");
  189.   standout("\nSubject:"); lprcat("  hope\n");
  190. #endif /*RFCMAIL*/
  191.   lprcat("\nCongratulations on your successful expedition.  We are sure much");
  192.   lprcat("\ncourage and determination were needed on your quest.  There are");
  193.   lprcat("\nmany though, that could never hope to undertake such a journey");
  194.   lprcat("\ndue to an enfeebling disease -- cancer.  We at the National");
  195.   lprcat("\nCancer Society of Larn wish to appeal to your philanthropy in");
  196.   lprcat("\norder to save many good people -- possibly even yourself a few");
  197.   lprcat("\nyears from now.  Much work needs to be done in researching this");
  198.   lprcat("\ndreaded disease, and you can help today.  Could you please see it");
  199.   lprcat("\nin your heart to give generously?  Your continued good health");
  200.   lprcat("\ncan be your everlasting reward.\n");
  201. # ifdef MAIL
  202.   lwclose();
  203. # endif
  204.   return(1);
  205.   }
  206.  
  207.  
  208. static int (*pfn[])()= { letter1, letter2, letter3, letter4, letter5, letter6 };
  209.  
  210. # ifdef MAIL
  211. /*
  212.  *  function to mail the letters to the player if a winner
  213.  */
  214. mailbill()
  215.     {
  216. #ifdef VMS
  217.     register int i;
  218.     char buf[128];
  219.     pid = getpid();
  220.     for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
  221.         if ((*pfn[i])()) {
  222.             sprintf(buf, "mail %s %s\n", loginname, mail600);
  223.             oneliner(buf);
  224.             delete(mail600);
  225.         }
  226.     }
  227. #else
  228.     register int i;
  229.     char buf[128];
  230.     wait(0);  pid=getpid();
  231.     if (fork() == 0)
  232.         {
  233.         resetscroll();
  234.         for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
  235.             if ((*pfn[i])())
  236.                 {
  237.                 sleep(20);
  238.                 sprintf(buf,"mail %s < %s",loginname,mail600);
  239.                 system(buf);  unlink(mail600);
  240.                 }
  241.         exit();
  242.         }
  243.     }
  244. #endif
  245. # else
  246.  
  247. /* Page the mail to the terminal    - dgk
  248.  */
  249. readmail(gold)
  250. long    gold;
  251. {
  252.     register int i;
  253.  
  254.     for (i = 0; i < (sizeof pfn) / (sizeof pfn[0]); i++) {
  255.         resetscroll();
  256.         clear();
  257.         (*pfn[i])(gold);    /* a bit dirty 'cause of args */
  258.         retcont();
  259.     }
  260. }
  261. # endif
  262.